<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:mtg="http://www.patelski.myself/jsf"
	template="layout/template.xhtml">

	<ui:define name="body">

		<rich:modalPanel id="addCardPopup" resizeable="false" width="500">
			<h:panelGrid id="addCardPopupGrid" columns="1" width="100%">
				<h:panelGrid columns="1" width="100%">
					<a:outputPanel id="addToInventory">
						<a:form id="addToInventoryForm">
							<h:panelGrid columns="2" width="100%">

								<h:outputText value="Card: " />
								<h:outputText id="cardName"
									value="#{inventoryHome.card.cardName}" />
								<h:outputText value="Number of copies: " />
								<h:inputText id="add" value="#{inventoryHome.instance.have}" />
								<h:outputText value="Keep: " />
								<h:inputText id="keep" value="#{inventoryHome.instance.keep}" />
								<h:outputText value="Sell each for: " />
								<h:inputText id="sellAmount"
									value="#{inventoryHome.instance.sellAmount}" />
								<h:outputText value="Bought these for: " />
								<h:inputText id="spent"
									value="#{inventoryHome.instance.totalAmount}" />
								<h:outputText value="Note: " />
								<h:inputText id="note" value="#{inventoryHome.instance.note}" />
								<h:inputHidden id="addCardId" value="#{inventoryHome.addCardId}" />
								<a:commandButton id="addToInventoryButton" value="Add Card"
									action="#{inventoryHome.addCard()}" reRender="messages"
									onclick="Richfaces.hideModalPanel('addCardPopup')" />
							</h:panelGrid>
						</a:form>
					</a:outputPanel>
				</h:panelGrid>
				<h:commandButton value="Close"
					onclick="Richfaces.hideModalPanel('addCardPopup')" />
			</h:panelGrid>
		</rich:modalPanel>

		<s:button view="/CardList.xhtml" id="grid" value="Show as List" />

		<h:form id="cardSearch" styleClass="edit">

			<rich:simpleTogglePanel label="Card search parameters"
				switchType="ajax">
				<s:decorate template="layout/display.xhtml">
					<ui:define name="label">Card name</ui:define>
					<h:inputText id="cardName" value="#{cardList.card.cardName}" />
				</s:decorate>
				<s:decorate template="layout/display.xhtml">
					<ui:define name="label">Foil?</ui:define>
					<h:selectOneMenu value="#{cardList.card.foil}">
						<s:selectItems value="#{enumLists.foilArray}" var="foil"
							label="#{foil.description}" />
					</h:selectOneMenu>

				</s:decorate>
			</rich:simpleTogglePanel>

			<div class="actionButtons"><h:commandButton id="search"
				value="Search" action="/CardGrid.xhtml" /></div>

		</h:form>
		<rich:panel>
			<f:facet name="header">Card search results</f:facet>
			<!-- div class="results" id="cardList"><h:outputText
				value="No cards found" rendered="#{empty cardList.resultList}" /> <h:form -->
				<rich:dataGrid value="#{cardList.resultList}" var="card"
					rendered="#{not empty cardList.resultList}" id="cardsTable"
					cellpadding="0px" cellspacing="0px" columns="5" elements="80"
					style="width:90%;">
					<f:facet name="header">
						<h:outputText value="Search results" />
					</f:facet>
					<mtg:cardQuickPanel card="#{card}" />

					<!-- f:facet name="footer">
						<rich:datascroller></rich:datascroller>
					</f:facet -->
				</rich:dataGrid>
			<!-- /h:form></div -->


		</rich:panel>
		<s:div styleClass="actionButtons" rendered="#{empty from}">
			<s:button view="/CardEdit.xhtml" id="create" value="Create card">
				<f:param name="cardId" />
			</s:button>
		</s:div>

	</ui:define>

</ui:composition>

